package itcast.dao.impl;

import itcast.dao.AdminDao;
import itcast.domain.Admin;
import itcast.util.JDBCUtils;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

//管理员数据操作类
public class AdminDaoImpl implements AdminDao {
    //实现template对象
    private JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());

    @Override
    public Admin findAdminByUsernameAndPassword(String admin_username, String admin_password) {

        //使用jdbc操作数据库
        //1.定义Sql
      try {
          String sql="select * from admin where Admin_Username=? and Admin_Password=?";
          Admin admin = template.queryForObject(sql,new BeanPropertyRowMapper<Admin>(Admin.class),admin_username,admin_password);
          return admin;
      }catch (Exception e){
          e.printStackTrace();
          return null;
      }






    }

}
